<!-- $Id: picture_batch.htm 8555 2007-05-10 06:53:29Z wj $ -->
{insert_scripts files="../js/utils.js"}
{include file="pageheader.htm"}
<div class="main-div">
<form action="picture_batch.php" method="post" name="theForm" onsubmit="return start()">
  <table align="center">
  <tr>
    <td>{$lang.notes}</td>
  </tr>
  <tr>
    <td><label for="process_thumb"><input type="checkbox" name="process_thumb" value="1" id="process_thumb" checked="true" />
    {$lang.thumb} 
</label>&nbsp;{$lang.frompage}
        <input name="startpage" type="text" id="startpage" value="1" maxlength="5"  style="width:30px;"/>
        &nbsp;{$lang.pagesize}
        <input name="page_size" type="text" id="page_size" value="50" maxlength="5"  style="width:30px;"/></td>
  </tr>
  <tr>
    <td><label for="process_watermark"><input type="checkbox" name="process_watermark" value="1" id="process_watermark" checked="true" />{$lang.watermark}</label></td>
  </tr>
  <tr>
    <td>
        <label for="yes_change"><input type="radio" name="change_link" value="1" id="yes_change" />{$lang.yes_change}</label>
        <label for="no_change"><input type="radio" name="change_link" value="0" checked="true" id="no_change" />{$lang.no_change}</label>
    </td>
  </tr>
  <tr>
    <td align="center">
      <input type="submit" value="{$lang.button_submit}" />
    </td>
  </tr>
  </table>
</form>
</div>

<div class="list-div" id="listDiv">
  <table cellspacing='1' cellpadding='3' id='listTable'>
    <tr>
      <th>{$lang.page}</th>
      <th>{$lang.total}</th>
      <th>{$lang.time}</th>
    </tr>
  </table>
</div>

<script type="Text/Javascript" language="JavaScript">
<!--
{literal}
onload = function()
{
    // 开始检查订单
    startCheckOrder();
}

/**
 * 开始处理数据
 */
function start()
{
    var thumb = document.forms['theForm'].elements['process_thumb'].checked ? 1 : 0;
    var watermark = document.forms['theForm'].elements['process_watermark'].checked ? 1 : 0;
    var change = document.forms['theForm'].elements['change_link'][0].checked? 1 : 0;
	var startpage = document.forms['theForm'].elements['startpage'].value;
	var page_size = document.forms['theForm'].elements['page_size'].value;

    if (thumb || watermark )
    {
        var tbl = document.getElementById("listTable");
        for (i = tbl.rows.length - 1; i > 0; i--)
        {
          tbl.deleteRow(i);
        }

        Ajax.call('picture_batch.php?is_ajax=1&start=1', 'thumb=' + thumb + '&watermark=' + watermark + '&change=' + change + '&startpage=' +startpage + '&page_size='+page_size , start_response, 'GET', 'JSON');
    }
    else
    {
        alert(no_action);
    }
    return false;
}

/**
 * 处理反馈信息
 * @param: result
 * @return
 */
function start_response(result)
{
    //没有执行错误
    if (result.error == 0)
    {
      if (result.done == 0)
      {
        //执行结束
        if (result.module_no > 0)
        {
          /* 结束时，删除多余的最后一行 */
          var tbl = document.getElementById("listTable"); //获取表格对象
          tbl.deleteRow(tbl.rows.length - 1);
        }
      }
      else
      {
        var cell;
        var tbl = document.getElementById("listTable"); //获取表格对象

        if (result.done == 1)
        {
          if (result.module_no > 0)
          {
            /* 已经换模块，删除多余的最后一行 */
            tbl.deleteRow(tbl.rows.length - 1);
          }
          /* 产生一个标题行 */
          var row = tbl.insertRow(-1);

          cell = row.insertCell(0);
          cell.className = 'first-cell';
          cell.colSpan = '3';
          cell.innerHTML = result.title ;
        }
        else
        {
          document.getElementById(result.row.pre_id).innerHTML = result.row.pre_time; //更新上一行执行时间
        }

        //创建新任务行
        var row = tbl.insertRow(-1);
        cell = row.insertCell(0);
        cell.innerHTML = result.row.new_page ;
        cell = row.insertCell(1);
        cell.innerHTML = result.row.new_total ;
        cell = row.insertCell(2);
        cell.id = result.row.cur_id;
        cell.innerHTML = result.row.new_time ;

        //提交任务
        Ajax.call('picture_batch.php?is_ajax=1', 'thumb=' + result.thumb + '&watermark=' + result.watermark + '&change=' + result.change + '&module_no=' + result.module_no + '&page=' + result.page + '&page_size=' + result.page_size + '&total=' + result.total +'&startpage=' + result.startpage , start_response, 'GET', 'JSON');
      }
    }

    if (result.message.length > 0)
    {
      //有信息则输出出错信息
      alert(result.message);
    }
}
{/literal}
//-->
</script>
{include file="pagefooter.htm"}